/** @file
 *  @par License 
 *  Copyright (C) 2010-2011 Intel Corporation. All Rights Reserved.
 *  
 **/

#ifndef KEN_GENERAL_KERNEL_STUB_INTERFACE_H
#define KEN_GENERAL_KERNEL_STUB_INTERFACE_H

#include "syspy/types.h"

#pragma warning(disable:4201)   // nameless struct/union
#pragma warning(disable:4127)   // do {} while (0)

#define KS_DEVICE_TYPE          40000
#define KS_DEVICE_FUNCTION      0x900
#define KS_DRIVER_MMIO_READ_FUNCTION    (KS_DEVICE_FUNCTION)
#define KS_DRIVER_IO_READ_FUNCTION      (KS_DEVICE_FUNCTION + 1)
#define KS_DRIVER_IO_WRITE_FUNCTION     (KS_DEVICE_FUNCTION + 2)
#define KS_DRIVER_IO_PORT_READ_FUNCTION (KS_DEVICE_FUNCTION + 3)
#define KS_DRIVER_MMIO_SCAN_FUNCTION    (KS_DEVICE_FUNCTION + 4)

#define KS_DRIVER_MMIO_READ \
    CTL_CODE(KS_DEVICE_TYPE, KS_DRIVER_MMIO_READ_FUNCTION, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define KS_DRIVER_IO_READ \
    CTL_CODE(KS_DEVICE_TYPE, KS_DRIVER_IO_READ_FUNCTION, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define KS_DRIVER_IO_WRITE \
    CTL_CODE(KS_DEVICE_TYPE, KS_DRIVER_IO_WRITE_FUNCTION, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define KS_DRIVER_IO_PORT_READ \
    CTL_CODE(KS_DEVICE_TYPE, KS_DRIVER_IO_PORT_READ_FUNCTION, METHOD_BUFFERED, FILE_ANY_ACCESS)

#define KS_DRIVER_MMIO_SCAN \
    CTL_CODE(KS_DEVICE_TYPE, KS_DRIVER_MMIO_SCAN_FUNCTION, METHOD_BUFFERED, FILE_ANY_ACCESS)

#pragma pack(1)
typedef struct {
    u32_t base;
    u32_t length;
} MMIO_READ_PARAM;

typedef struct {
    u32_t port;
    u32_t width;
    u32_t value;
} IO_PARAM;

typedef struct {
    u32_t index_port;
    u32_t data_port;
    u8_t  buffer[128];
} IO_PORT_PARAM;

typedef struct {
    u32_t start;
    u32_t length;
    u32_t scan_buffer_len;
    u8_t  scan_buffer[0x1000];       // the length of scan buffer should not exceed 0x1000
} MMIO_SCAN_PARAM;
#pragma pack()

#endif // TD_SLEEP_COUNT_INTERNAL_H

